/**
 * com.cnhis.his.customer.service.Abu1Service.java
 */
package com.mbmed.doctor.homepage.service;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletResponse;
import javax.ws.rs.Consumes;
import javax.ws.rs.DELETE;
import javax.ws.rs.FormParam;
import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.QueryParam;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Request;

import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import com.mbmed.doctor.commons.mapper.ModelVo;
import com.mbmed.doctor.homepage.bo.Abu1Bo;
import com.mbmed.doctor.homepage.mapper.Abu1;

/**
 * @file  Abu1Service.java
 * @author 刘武
 * @version 0.1
 * @todo	Abu1服务操作接口
 * Copyright(C), 2013-2014
 *		 Shenzhen Coordinates Software Development Co., Ltd.
 * History
 *   	1. Date: 2014-11-24 07:22:06
 *      	Author: 刘武
 *      	Modification: this file was created
 *   	2. ...
 */
@Path("/abu1")
@Component
public class Abu1Service {
	
	private static Logger logger = Logger.getLogger(Abu1.class);
	
	@Autowired
	private Abu1Bo abu1Bo;
	
	@Context
	Request request;

	
	/**
	 * 查找所有数据库记录
     * @return type : List 返回查询操作所有符合条件的记录的VO对象集合，操作失败返回null
     */
	@GET
	@Produces({MediaType.APPLICATION_XML,MediaType.APPLICATION_JSON})
    public List<Abu1> getAll() throws Exception{
        List<Abu1> list = new ArrayList<Abu1>();
        return abu1Bo.getAll();        
    }
	
    /**
     * 查找符合条件的所有数据库记录
     * @param id 与数据库中主键对应的值
     * @return type :  返回查询操作所有符合条件的记录的VO对象，操作失败返回null
     * @throws Exception
     */
	@GET
	@Path("{id}")
	@Produces({MediaType.APPLICATION_XML,MediaType.APPLICATION_JSON})
    public Abu1 getAbu1(@PathParam("id") String id) throws Exception{
    	Abu1 abu1 = null;
    	return abu1Bo.get(id);        
    }
	
	
	/**
     * 检索籍贯省
     * @param id 与数据库中主键对应的值
     * @return type :  返回查询操作所有符合条件的记录的VO对象，操作失败返回null
     * @throws Exception
     */
	@GET
	@Path("/getabu1jgsheng")
	@Produces({MediaType.APPLICATION_JSON})
    public ModelVo getAbu1JgSheng(
    		@QueryParam("txt") java.lang.String txt
    		) throws Exception{
		ModelVo modelvo = new ModelVo();
		List<Abu1>  list = new ArrayList<Abu1>();
		list = abu1Bo.getAbu1JgSheng(txt);
		modelvo.setList(list);
    	return modelvo;
	}
	
	
	
	/**
     * 检索籍贯市
     * @param id 与数据库中主键对应的值
     * @return type :  返回查询操作所有符合条件的记录的VO对象，操作失败返回null
     * @throws Exception
     */
	@GET
	@Path("/getabu1jgshi")
	@Produces({MediaType.APPLICATION_JSON})
    public ModelVo getAbu1JgShi(
    		@QueryParam("abu02a") java.lang.String abu02a,
    		@QueryParam("lvvnr") java.lang.String lvvnr
    		) throws Exception{
		ModelVo modelvo = new ModelVo();
		Map<String,Object> map = new HashMap<String,Object>();
		List<Abu1>  list = new ArrayList<Abu1>();
		map.put("abu02a",abu02a);
		map.put("lvvnr",Integer.parseInt(lvvnr));
		list = abu1Bo.getAbu1JgShi(map);
		modelvo.setList(list);
    	return modelvo;
	}
	
	
	
    /**
     * 向数据库中插入一条记录
     * @param vo 与数据库中记录对应的值对象
     * @return type : 返回插入操作是否成功
     * @throws Exception
     */
	@POST
	@Produces(MediaType.APPLICATION_JSON)
	@Consumes(MediaType.APPLICATION_FORM_URLENCODED)
	public Abu1 saveAbu1(
			@FormParam("abu01") java.lang.String abu01,
			@FormParam("abu02") java.lang.String abu02,
			@FormParam("abu03") java.lang.String abu03,
			@FormParam("abbrp") java.lang.String abbrp,
			@FormParam("abbrw") java.lang.String abbrw,
			@FormParam("abu01a") java.lang.String abu01a,
			@FormParam("lvlnr") java.lang.Integer lvlnr,
			@FormParam("enabl") java.lang.Byte enabl,
			@FormParam("abu09") java.lang.String abu09,
			@FormParam("abu10") java.lang.String abu10,
			@FormParam("isdef") java.lang.Byte isdef,
			@Context HttpServletResponse servletResponse
	) throws Exception {
		Abu1 abu1 = new Abu1();
		abu1.setAbu01(abu01);
		abu1.setAbu02(abu02);
		abu1.setAbu03(abu03);
		abu1.setAbbrp(abbrp);
		abu1.setAbbrw(abbrw);
		abu1.setAbu01a(abu01a);
		abu1.setLvlnr(lvlnr);
		abu1.setEnabl(enabl);
		abu1.setAbu09(abu09);
		abu1.setAbu10(abu10);
		abu1.setIsdef(isdef);

		return abu1 = abu1Bo.save(abu1);

	}
	/**
     * 删除数据库中与传入的值对象对应的记录
     * @param vo 与数据库中记录对应的值对象
     * @return type : boolean 返回删除操作是否成功
     * @throws Exception
     */
	@DELETE
	@Path("{id}")
	public boolean removeAbu1(@PathParam("id") String id) throws Exception{
		if(id == null) return false;
    	return abu1Bo.remove(id);

	}
	
}
